//
//  ByUserIndexDoctorDetailVC.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/12.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByUserIndexDoctorDetailVC.h"

// cell
#import "ByCellLookDoctorDetail.h"
#import "ByCellLookDoctorHeader.h"

@interface ByUserIndexDoctorDetailVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, copy) NSArray *titles;
@property (nonatomic, copy) NSArray *contents;
@end

@implementation ByUserIndexDoctorDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.model.nick_name;
    self.model.intro = @"医生简介啊该回复故很少党纪国法会接收到个房间";
    self.model.skill = @"擅长神盾局返回角色的回复";
    self.model.position = @"hjdshfjsgd或点击烦回家";
    [self createViews];
    [self addLeftBackBarButtonItem];
}

#pragma mark - create views
- (void)createViews{
    UIButton *consultButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:consultButton];
    [consultButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 40));
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        }else{
            make.bottom.equalTo(self.view.mas_bottom);
        }
    }];
    [consultButton setTitle:@"健康咨询" forState:UIControlStateNormal];
    [consultButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    consultButton.backgroundColor = BY_THEME_COLOR;
    
    self.tableView = [[UITableView alloc] init];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.bottom.equalTo(consultButton.mas_top);
        make.right.equalTo(@(0));
        if (@available(iOS 11.0,*)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
        }else{
            make.top.equalTo(self.view.mas_top);
        }
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = BY_TABLE_COLOR;
    
}

#pragma mark - getter
- (NSArray *)titles{
    if (!_titles) {
        _titles = @[@"执业点",@"擅长疾病",@"医生简介"];
    }
    return _titles;
}

- (NSArray *)contents{
    if (!_contents) {
        _contents = @[_model.position,_model.skill,_model.intro];
    }
    return _contents;
}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        ByCellLookDoctorHeader *cell = [ByCellLookDoctorHeader cellWithTableView:tableView];
        cell.model = self.model;
        return cell;
    }else{
        ByCellLookDoctorDetail *cell = [ByCellLookDoctorDetail cellWithTableView:tableView andTitle:self.titles[indexPath.section - 1] andContent:self.contents[indexPath.section - 1]];
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (@available(iOS 11.0,*)) {
        return (self.view.height - self.view.safeAreaInsets.bottom - 40) / 4;
    }
    return (SCREEN_HEIGHT - 40) / 4;
}
@end
